import pytest
import requests
import json
import logging
def dearjson():
    with open(file="xz.json",mode="r",encoding="utf8") as f:
        data=json.load(f)
        return data
class TestAdd():
    thoken=None
    def setup_method(self):
        print("执行前")
    def teardown_method(self):
        print("执行后")
    def test_dl(self):
        url="http://10.59.9.21/api/user/login"
        body={"username":"admin","password":"8i4De25KlVQVwqTDgTNGqw=="}
        r=requests.post(url=url,json=body)
        print(r.json())
        TestAdd.thoken=r.json()["token"]
    @pytest.mark.parametrize("data",dearjson())
    def test_xzdq(self,data):
        url="http://10.59.9.21/api/area/add"
        headers={"uid":"1","token":TestAdd.thoken}
        body={"atype":2,"name":data.get("dz"),"sort":data.get("bh")}
        r=requests.post(url=url,headers=headers,json=body)
        print(r.json())
